package com.example.dragandview.diywidget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.dragandview.R;

public class ItemView extends RelativeLayout {
    private TextView tvLeft;
    private TextView tvRight;
    private ImageView ivArrow;
    public ItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.item_layout, this);
        tvLeft = findViewById(R.id.tvLeft);
        tvRight = findViewById(R.id.tvRight);
        ivArrow = findViewById(R.id.ivArrow);
    }
    /**
     * 设置内容
     *
     * @param tvLeftStr   左边内容
     * @param tvRightStr     右边内容
     * @param isShowArrow 是否显示小箭头
     */
    public void setView(String tvLeftStr, String tvRightStr, boolean isShowArrow) {

        if (tvLeftStr != null) {
            tvLeft.setText(tvLeftStr);
        }

        if (tvRightStr != null) {
            tvRight.setText(tvRightStr);
        }

        if (isShowArrow) {
            ivArrow.setVisibility(View.VISIBLE);
        } else {
            ivArrow.setVisibility(View.GONE);
        }

    }
}
